package com.rabbitmq.demo.producer;

import com.google.gson.Gson;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by dangjing on 18-8-24.
 */
@Component
public class HelloSender {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send1(Object obj){
//        String context = "hello"+new Date();
        Gson gson = new Gson();
        System.out.println("Sender1 : "+gson.toJson(obj));
        this.amqpTemplate.convertAndSend("hello",gson.toJson(obj));
    }

    public void send2(Object obj){
//        String context = "hello"+new Date();
        Gson gson = new Gson();
        System.out.println("Sender2 : "+gson.toJson(obj));
        this.amqpTemplate.convertAndSend("hello",gson.toJson(obj));
    }
}
